/* tslint:disable */
<%- buildModelImports(model) %>
declare var Object: any;
export interface <%- modelName %>Interface {
<%- buildModelProperties(model, true) %>
}

export class <%- modelName %> implements <%- modelName %>Interface {
<%- buildModelProperties(model) %>
  constructor(data?: <%- modelName %>Interface) {
    Object.assign(this, data);
  }
  /**
   * The name of the model represented by this $resource,
   * i.e. `<%- modelName %>`.
   */
  public static getModelName() {
    return <%-: modelName | q %>;
  }
  /**
  * @method factory
  * @author Jonathan Casarrubias
  * @license MIT
  * This method creates an instance of <%- modelName %> for dynamic purposes.
  **/
  public static factory(data: <%- modelName %>Interface): <%- modelName %>{
    return new <%- modelName %>(data);
  }
  /**
  * @method getModelDefinition
  * @author Julien Ledun
  * @license MIT
  * This method returns an object that represents some of the model
  * definitions.
  **/
  public static getModelDefinition() {
    return {
      name: '<%- modelName %>',
      plural: '<%- plural %>',
      path: '<%- path || plural %>',
      idName: '<%- Object.prototype.toString.call(model.sharedClass.ctor.getIdName) == '[object Function]' ? model.sharedClass.ctor.getIdName() : 'id' %>',
      properties: {<% for ( var prop in model.properties ) { %>
        "<%= prop %>": {
          name: '<%= prop %>',
          type: '<%= buildPropertyType( model.properties[prop] ) %>'<% if ( model.properties[prop].hasOwnProperty( "default" ) ) { %>,
          default: <%- buildPropertyDefaultValue( model.properties[prop] ) %><% } %>
        },<% } %>
      },
      relations: {<% for ( var rel in model.sharedClass.ctor.relations ) { %>
        <%= rel %>: {
          name: '<%= rel %>',
          type: '<%- buildRelationType( model, rel ) %>',
          model: '<%- model.sharedClass.ctor.relations[rel].targetClass %>',
          relationType: '<%- model.sharedClass.ctor.relations[rel].type %>',
        <% if (model.sharedClass.ctor.relations[rel].modelThrough && model.sharedClass.ctor.relations[rel].keyThrough) { %>  modelThrough: '<%- capitalize(model.sharedClass.ctor.relations[rel].modelThrough.definition.name) %>',
          keyThrough: '<%- model.sharedClass.ctor.relations[rel].keyThrough %>',
<% } -%>
          keyFrom: '<%- model.sharedClass.ctor.relations[rel].keyFrom %>',
          keyTo: '<%- model.sharedClass.ctor.relations[rel].keyTo %>'
        },<% } %>
      }
    }
  }
}
